<?php 
	session_start(); 
		if(isset($_SESSION['email'])){ echo "<script language=\"javascript\"> alert (\"already registered\");location.href=\"index.php\";</script>";}
?>
<html>
<head>
<style type="text/css">
	<!--
	#add_party {
	position:static;
	display:block;
	top: 460px;
	left: 60px;
	}
	#del_party {
		position:static;
		display:block;
		top: 2500px;
		left: 60px;
	}
	#view {
		position:static;
		display:block;
		top: 460px;
		left: 60px;
	}
	middle {
	height: 374px;
	width: 1024px;
	position: relative;
}
	-->
	</style>
	<script type="text/javascript">
	function echeck(str) 
	{

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1)
		{
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		{
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		{
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1)
		{
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		{
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1)
		{
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1)
		{
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function ValidateMail(form)
{
	email=document.add_party.email.value;
	
	if (email==""||email.indexOf("'")!=-1)
	{
		alert("Please Enter your Email ID. Email ID cannot contain ( ' )")
		document.add_party.email.focus();
		return false
	}
	if (echeck(email)==false)
	{
		email="";
		document.add_party.email.focus();
		return false
	}
	return true
 }
	

		
	function AddParty(form)
	{
		name=document.add_party.name.value;
		college=document.add_party.college.value;
		age=document.add_party.age.value;
		email=document.add_party.email.value;
		contactph=document.add_party.officeph.value;
		add=document.add_party.address.value;
		pass1=document.add_party.pass1.value;
		pass2=document.add_party.pass2.value;
	if(name=="")
	{
		alert("Enter name");
		document.add_party.name.focus();
		return;
	}
	
	
	if(college=="")
	{
		alert("Enter college's name");
		document.add_party.college.focus();
		return;
	}
	if(pass1=="")
	{
		alert("Enter password");
		document.add_party.pass1.focus();
		return;
	}	
	if(pass2==pass1)
	{
		
	}	
	else{
	alert("passwords do not match ");
		document.add_party.pass2.focus();
		return;
		}
		
	if(age=="")
	{
		alert("Enter age ");
		document.add_party.age.focus();
		return;
	}	
	ret=ValidateMail();
        if(ret==false)
        {
        return
        }
	if(contactph=="")
	{
		alert("Enter contact no.");
		document.add_party.officeph.focus();
		return;
	}	
	if(contactph!="")
{
var no = /^([0-9]{10})$/; 
if(!no.test(contactph))
{
alert("Please enter valid phone number");
document.add_party.officeph.focus();
return false; 
}
}
		
	if(add=="")
	{
		alert("Enter address");
		document.add_party.address.focus();
		return;
	}			
	document.add_party.submit();
	}
	
	</script>
<title>register</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" background="images/bgk.jpg">
<!-- ImageReady Slices (Admin_template.psd) -->
<table id="Table_01" width="300" border="0" cellpadding="0" cellspacing="0" align="center">
	<tr>
		<td colspan="10" width="300" ><div id="add_party" class="middle" align="center"><form name="add_party" action="reg.php" method="post"><table width="300" border="0" cellspacing="0" cellpadding="0">
	  <tr><td>&nbsp;</td>
	  </tr>
	  <tr>
		<td>&nbsp;</td>
		<td class="style5">&nbsp;</td>
		<td>&nbsp;</td>
		<td colspan="2" rowspan="7"></td>
		</tr>
	  <tr>
		<td>&nbsp;</td>
		<td class="style5">Name : </td>
		<td><input type="text" name="name"></td>
		</tr> 
	   <tr>
		<td>&nbsp;</td>
		<td class="style5">&nbsp;</td>
		<td>&nbsp;</td>
		</tr>
		<tr>
		<td>&nbsp;</td>
		<td class="style5">PASSWORD : </td>
		<td><input type="password" name="pass1"></td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	  </tr>
	  <tr>
		<td>&nbsp;</td>
		<td class="style5">&nbsp;</td>
		<td>&nbsp;</td>
		</tr>
		<tr>
		<td>&nbsp;</td>
		<td class="style5">CONFIRM  PASSWORD : </td>
		<td><input type="password" name="pass2"></td>
		
	  </tr>
	   <tr>
		<td>&nbsp;</td>
		<td class="style5">&nbsp;</td>
		<td>&nbsp;</td>
		</tr>
	  <tr>
		<td>&nbsp;</td>
		<td class="style5">College name : </td>
		<td><input type="text" name="college"></td>
		</tr> <tr>
		<td>&nbsp;</td>
		<td class="style5">&nbsp;</td>
		<td>&nbsp;</td>
		</tr>
	  <tr>
		<td>&nbsp;</td>
		<td class="style5">Age : </td>
		<td><input type="text" name="age" ></td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	  </tr> <tr>
		<td>&nbsp;</td>
		<td class="style5">&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	  </tr>
	  <tr>
		<td>&nbsp;</td>
		<td class="style5">E-mail  : </td>
		<td><input type="text" name="email"></td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	  </tr>
	   <tr>
		<td>&nbsp;</td>
		<td class="style5">&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	  </tr>
	   <tr>
		<td>&nbsp;</td>
		<td class="style5">Contact No. : </td>
		<td class="style5"><input type="text" name="officeph"></td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	  </tr>
	   <tr>
		<td>&nbsp;</td>
		<td class="style5">&nbsp;</td>
		<td class="style5">&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	  </tr>
	   <tr>
		<td>&nbsp;</td>
		<td class="style5">Address : </td>
		<td rowspan="3" class="style5"><textarea name="address" cols="20" rows="4"></textarea></td>
		</tr>
	   <tr>
		<td>&nbsp;</td>
		 </tr>
	   <tr>
		<td>&nbsp;</td>
	  </tr>
	  
	  <tr>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	  </tr>
	 <tr>
	    <td>&nbsp;</td>
	    <td>&nbsp;</td>
	    <td>&nbsp;</td>
	    <td>&nbsp;</td>
	    <td>&nbsp;</td>
	    </tr>
	  <tr>
		<td height="15">&nbsp;</td>
		<td>&nbsp;</td>
		<td><input type=button class="button" value="Register" onClick="AddParty()"></td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	  </tr>
	  <tr>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	  </tr>
	</table>
		</form></div></td></tr></table></body></html>